#include "connection.h"

#include <QMessageBox>
#include <QDebug>
#include <QSqlError>

connection::connection()
{

}

void connection::init(QSqlDatabase m_db)
{
    m_db = QSqlDatabase::addDatabase("QSQLITE");

    m_db.setDatabaseName("D:\\data.db");
    m_db.open();

    bool ok = m_db.open();
    if (ok){
        QMessageBox::information(nullptr, "infor", "MySQL connect success");
    }
    else
    {
        QMessageBox::information(nullptr, "infor", "open failed");
        qDebug()<<"error open database because"<<m_db.lastError().text();
    };
}
